import { http } from '@/utils/http'
import { baseURLApi } from '../utils'

export type PageResult<T> = {
  total: number
  list: Array<T>
}
export type WikiVO = {
  id: number
  title: string
  cover: string
  summary: string
  visitCount: number
  articleCount: number
  isTop: number
  createTime: Date
  updateTime: Date
}
export type WikiPage = {
  pageSize: number
  currentPage: number
  title?: string
}
export type WikiCatalog = {
  id: number
  icon: string
  title: string
  articleId: number
  children: Array<WikiCatalog>
}
export const getWikiPage = (data: WikiPage) => {
  return http.request<PageResult<WikiVO>>('get', baseURLApi('/wiki'), { params: data })
}

export const getWikiCatalog = (id: number) => {
  return http.request<Array<WikiCatalog>>('get', baseURLApi(`/wiki/catalog/${id}`))
}
export const getWikiArticleId = (id: number) => {
  return http.request<number>('get', baseURLApi(`/wiki/article/${id}`))
}
